package schoolWord;

import java.util.Random;



public class Test2 {
    public static void main(String[] args) {
        //定义一个数组
        int[] students = new int[50];
        for (int i = 0; i < 50; i++) {
            students[i] = i+1;
        }
        //随机数
        Random random = new Random();

        //先搞三等奖
        int[] arr3 = new int[3];
        for(int i = 0; i < 3; i++) {
            int index = random.nextInt(students.length);
            arr3[i] = students[index];
            students[index] = students[students.length-1];
            students = copy(students,students.length-1);
        }

        //再抽二等奖
        int[] arr2 = new int[2];
        for (int i = 0; i < 2; i++) {
            int index = random.nextInt(students.length);
            arr2[i] = students[index];
            students[index] = students[students.length-1];
            students = copy(students,students.length-1);
        }

        //抽一等奖
        int first = students[random.nextInt(students.length)];



        System.out.println("三等奖：" + arr3[0]+ " " + arr3[1] + " " + arr3[2]);
        System.out.println("二等奖：" + arr2[0] +" " + arr2[1]);
        System.out.println("一等奖：" + first);



    }

    public static int[] copy(int[] array ,int index) {
         int[] newArr = new int[array.length-1];
         System.arraycopy(array,0,newArr,0,index);  //复制拷贝到新数组
        System.arraycopy(array,index+1,newArr,index,array.length-index-1);  //删除元素
        return newArr;
    }
}
